import { environment } from '../../environments/environment';
import { Component, OnInit } from '@angular/core';
import { WebsocketService } from "../shared/websocket.service";
import 'rxjs/Rx';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {

  public messageCount:number = 0;
  title = environment.appTitle;
  constructor(public wsService:WebsocketService) { }

  ngOnInit() {
    this.wsService.conncetWebSocket('ws://localhost:8001').
    map(event => JSON.parse(event)).subscribe(
      data=>this.messageCount = data.messageCount
    )
  }

}
